package com.xuanting.xuanting

import android.os.Bundle
import android.support.v4.app.Fragment
import android.support.v7.widget.LinearLayoutManager
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.BaseViewHolder
import kotlinx.android.synthetic.main.fragment_test.*

/**
 * Created by lijianbin on 2018/12/5.
 */
class TestFragment : Fragment() {

    companion object {
        fun newInstance() = TestFragment()
    }

    override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
        return setRootView(inflater, null, false)
    }

    override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
        super.onViewCreated(view, savedInstanceState)
        initData()
        initWidget()

    }

    private fun initWidget() {

        val data=ArrayList<String>()

        for(i in 0..100){
            data.add("條目")
        }

        rv.layoutManager=LinearLayoutManager(context)
        rv.adapter=MyAdapter(data)
    }

    private fun initData() {
    }

    private fun setRootView(inflater: LayoutInflater?, container: ViewGroup?, attachToRoot: Boolean): View? {
        return inflater!!.inflate(R.layout.fragment_test, container, attachToRoot)
    }

    class MyAdapter(data:ArrayList<String>):  BaseQuickAdapter<String, BaseViewHolder>(R.layout.item_home, data) {

        override fun convert(helper: BaseViewHolder, item: String) {
//        val view = helper.getView<ImageView>(R.id.item_iv_shop)
//        Glide.with(mContext).load(item.shopImage).into(view)

        }
    }
}
